using System;
using Org.EasyWeb.Exception;
using Org.EasyWeb.Sys;
using Org.EasyWeb.SysUtil;
using Org.EasyWeb.Web;

namespace Org.EasyWeb.Right.Data
{
	public class WebBaseLoginPage : WebXmlHttp2Page
	{
        private string fDefaultPage;

		public WebBaseLoginPage() 
		{
		}

		protected string DefaultPage
		{
			get
			{
				return fDefaultPage;
			}
			set
			{
				fDefaultPage = value;
			}
		}

		public LoginBaseDataSet Generator
		{
			get
			{
				return (LoginBaseDataSet)Source;
			}
		}

		protected override void SetData()
		{
			Generator.CreateLoginTable();
			Generator.SetDefaultValue(Request);
		}

		protected override void DoPost()
		{
			Generator.CreateLoginTable();
            //EditPage.PostData(PostDataSet, UpdateKind.Update);
            HttpPostPage.Post(PageStyle.Custom, "Login", Request.QueryString, PostDataSet);
			SucceedCommit();
		}

		protected override void HandleInformation(InformationException ex)
		{
			string content = GetXmlString();
            Response.ContentEncoding = System.Text.Encoding.UTF8;
			Response.Write(TransformUtil.Transform(content, Transform.IeFiles.Content));
		}

		protected string RedirectPath()
		{
			string retURL = Request.QueryString["RetURL"];
			if (IsPost)
				retURL = PostDataSet.Tables["OtherInfo"].Rows[0]["Save"].ToString();
			return (retURL == string.Empty) ? fDefaultPage : retURL;
		}

	}
}
